package com.example.demofile.config;

import com.example.demofile.common.Constants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
 
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

    @Value("${file.path}")
    private String file_path;

    /**
     * 资源映射配置
     *
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(Constants.FILE_MAP)
                .addResourceLocations("file:" + file_path);
        
        super.addResourceHandlers(registry);
    }
}